//
//  HomeTabHeadView.m
//  Bread-Live
//
//  Created by ios on 2017/3/13.
//  Copyright © 2017年 Chris. All rights reserved.
//

#import "HomeTabHeadView.h"
#import "SDCycleScrollView.h"
#import "TypeScrollView.h"


@interface HomeTabHeadView ()
@property(nonatomic,strong)SDCycleScrollView *cycleScrollView;
@property(nonatomic,strong)TypeScrollView    *typeView;


@end



@implementation HomeTabHeadView

-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        
    }
    return self;
}

-(void)addImageData:(NSArray *)imageArray{
    
    _imageData = imageArray;
    [self configView];
}

-(void)configView{
    CGFloat viewW = self.frame.size.width;
    CGFloat viewH = self.frame.size.height;
    
    _cycleScrollView                    = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(0, 0, viewW, viewH-kWidth/5) shouldInfiniteLoop:YES imageNamesGroup:self.imageData];
    
    _cycleScrollView.pageControlAliment = SDCycleScrollViewPageContolAlimentRight;
    
    [self addSubview:_cycleScrollView];
    
    _typeView = [[TypeScrollView alloc] initWithFrame:CGRectMake(0, viewH-kWidth/5, viewW, kWidth/5)];
    
    [_typeView addItemData:@[@"推荐",@"健身",@"职场",@"母婴",@"时尚"] andImageData:@[@"type-1",@"type-2",@"type-3",@"type-4",@"type-5"]];
    WS(weakSelf);
    _typeView.block = ^(NSString *title,NSInteger index){
        WYLog(@"show%@----%ld",title,index);
        
        if ([weakSelf.delegate respondsToSelector:@selector(refreshListViewTitle:btnIndex:)]) {
            
            [weakSelf.delegate refreshListViewTitle:title btnIndex:index];
        }
    };
    
    [self addSubview:_typeView];
    
}



/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
